
import codecs

import jieba.posseg as pseg
import jieba.analyse

f = codecs.open(r'C:\\Users\\gaoya\\Desktop\\新建文本文档.txt', 'r', encoding='utf-8')
for line in f.readlines():
    line = line.strip('\n').strip('\r')
    print(line)

    seg_list = pseg.cut(line)
    fenciList = []
    for w in seg_list:
        fenciList.append(w.word+w.flag)
    print('/'.join(fenciList))

    tags = jieba.analyse.textrank(line, topK=3, withWeight=True)
    for tag in tags:
        print("tag: %s\t\t weight: %f" % (tag[0],tag[1]))
